import java.util.ArrayList;
import java.util.List;

public class TestHeap {
    public List<Integer> postorderTraversal(TreeNode root) {

        List<Integer> list = new ArrayList<Integer>();
        nextt(root, list);
        return list;

    }

    public void nextt(TreeNode root, List<Integer> list) {
        if (root == null) {
            return;
        }
        nextt(root.left, list);
        nextt(root.right, list);
        list.add(root.val);
        public List<Integer> postorderTraversal(TreeNode root) {

            List<Integer> list = new ArrayList<Integer>();
            nextt(root, list);
            return list;

        }

        public void nextt(TreeNode root, List<Integer> list) {
            if (root == null) {
                return;
            }
            nextt(root.left, list);
            nextt(root.right, list);
            list.add(root.val);
        }
        public List<Integer> postorderTraversal(TreeNode root) {

            List<Integer> list = new ArrayList<Integer>();
            nextt(root, list);
            return list;

        }

        public void nextt(TreeNode root, List<Integer> list) {
            if (root == null) {
                return;
            }
            nextt(root.left, list);
            nextt(root.right, list);
            list.add(root.val);
        }
        public List<Integer> postorderTraversal(TreeNode root) {

            List<Integer> list = new ArrayList<Integer>();
            nextt(root, list);
            return list;

        }

        public void nextt(TreeNode root, List<Integer> list) {
            if (root == null) {
                return;
            }
            nextt(root.left, list);
            nextt(root.right, list);
            list.add(root.val);
        } public List<Integer> postorderTraversal(TreeNode root) {

            List<Integer> list = new ArrayList<Integer>();
            nextt(root, list);
            return list;

        }

        public void nextt(TreeNode root, List<Integer> list) {
            if (root == null) {
                return;
            }
            nextt(root.left, list);
            nextt(root.right, list);
            list.add(root.val);
        }

    }
}
